package com.gltqe.mask;

/**
 * 脱敏默认处理器
 *
 * @author gltqe
 * @date 2023/6/17 21:42
 */
public class DefaultDataMaskHandle implements DataMaskHandle {
    @Override
    public Object dataMaskHandle(DataMask dataMask, String fieldValue) {
        DefaultMaskType type = dataMask.type();
        return defaultMask(type, fieldValue);
    }

    public static String defaultMask(DefaultMaskType type, String fieldValue) {
        switch (type) {
            case NAME:
                return DataMaskUtil.maskName(fieldValue);
            case PHONE:
                return DataMaskUtil.maskPhone(fieldValue);
            case ID_CARD:
                return DataMaskUtil.maskIdCard(fieldValue);
            case BANK_CARD:
                return DataMaskUtil.maskBankCard(fieldValue);
            case EMAIL:
                return DataMaskUtil.maskEmail(fieldValue);
            case ADDRESS:
                return DataMaskUtil.maskAddress(fieldValue);
            case IP_ADDRESS:
                return DataMaskUtil.maskIpAddress(fieldValue);
            default:
                return DataMaskUtil.defaultMask(fieldValue);
        }
    }
}
